package de.zainodis.triplog.ui;

import android.app.Activity;

import com.j256.ormlite.android.apptools.OpenHelperManager;

import de.zainodis.triplog.data.persistence.DatabaseHelper;

/**
 * Created by fzarrai on 9/10/2014.
 */
public class OpenHelperActivity extends Activity {

    private DatabaseHelper databaseHelper = null;

    protected DatabaseHelper getHelper() {
        //Lazy loading the database helper
        if (databaseHelper == null) {
            databaseHelper =
                    OpenHelperManager.getHelper(this, DatabaseHelper.class);
        }
        return databaseHelper;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (databaseHelper != null) {
            OpenHelperManager.releaseHelper();
            databaseHelper = null;
        }
    }
}
